package com.shangqing.document_management.service.serviceImpl;

import com.shangqing.document_management.entity.DocumentRegistration;
import com.shangqing.document_management.mapper.DocumentRegistrationMapper;
import com.shangqing.document_management.service.IDocumentRegistrationService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.UUID;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 
 * @since 2020-12-22
 */
@Transactional
@Service
public class DocumentRegistrationServiceImpl extends ServiceImpl<DocumentRegistrationMapper, DocumentRegistration> implements IDocumentRegistrationService {
@Autowired
DocumentRegistrationMapper documentRegistrationMapper;

    /**
     * 获得UUID
     * @return
     */
 public static String getUUID32(){
     return UUID.randomUUID().toString().replace("-","").toLowerCase();
 }
    @Override
    public Boolean addDocumentRegistration(DocumentRegistration documentRegistration) {
     if(documentRegistration!=null){
         documentRegistration.setNumber(getUUID32());
     }
        int i=documentRegistrationMapper.addDocumentRegistration(documentRegistration);
        Boolean flage=false;
        if(i>0){
            flage=true;
        }else{
            flage=false;
        }

        return flage;
    }
}
